/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: HP
 * Date: 2023 -04 -29
 * Time: 23:30
 */


public class SemiCircle extends GeoGraph{
    private int r;
    public SemiCircle(){};
    public SemiCircle(int r) {
        this.r = r;
    }

    @Override
    public double getArea() {
        return Math.PI*r*r/2;
    };

    @Override
    public double getPerimeter() {
        return Math.PI*r + 2*r;
    };

    @Override
    public int compareTo(GeoGraph o) {
        return (int)(getArea() - o.getArea());
    };

    @Override
    public void procColor(GeoGraph o) {
        int color = (int)getArea();
        while(color >= 100) {
            color /= 10;
        }
        setColor(color);
    };

    public String toString() {
        return ("半圆的面积是：  "+getArea());
    }

}

